INC:= ./src
CFLAGS:=-L${INC}

SRC_DIR:=./src/
BUILD_DIR:=./build/

SRC := $(notdir $(wildcard ${SRC_DIR}*.cpp))
OBJ := $(patsubst %.cpp,%.o, ${SRC})
OBJS := $(addprefix ${BUILD_DIR}, ${OBJ})

${BUILD_DIR}main.exe: ${OBJS}
	g++ ${CFLAGS} $^ -o $@

${BUILD_DIR}%.o: ${SRC_DIR}%.cpp
	g++ -c ${CFLAGS} $< -o $@

test: ${BUILD_DIR}main.exe
	${BUILD_DIR}main.exe -test tests/00/00.txt tests/01/01.txt tests/02/02.txt tests/07/07.txt

ll: ${BUILD_DIR}main.exe
	${BUILD_DIR}main.exe -ll1 tests/00/00.txt tests/01/01.txt tests/02/02.txt tests/07/07.txt

lr: ${BUILD_DIR}main.exe
	${BUILD_DIR}main.exe -lr1 tests/00/00.txt tests/01/01.txt tests/02/02.txt tests/07/07.txt

error: ${BUILD_DIR}main.exe
	${BUILD_DIR}main.exe -test tests/08/08.txt tests/10/10.txt

.PHONY: clean rm

clean:
	del .\build\*.o .\build\main.exe
	del .\tests\00\*gra.txt .\tests\00\*lex.txt
	del .\tests\01\*gra.txt .\tests\01\*lex.txt
	del .\tests\02\*gra.txt .\tests\02\*lex.txt
	del .\tests\07\*gra.txt .\tests\07\*lex.txt
	del .\tests\08\*gra.txt .\tests\08\*lex.txt
	del .\tests\10\*gra.txt .\tests\10\*lex.txt

rm:
	rm ./build/*.o ./build/main.exe
	rm ./tests/00/*gra.txt ./tests/00/*lex.txt ./tests/00/*gra-lr.txt
	rm ./tests/01/*gra.txt ./tests/01/*lex.txt ./tests/01/*gra-lr.txt
	rm ./tests/02/*gra.txt ./tests/02/*lex.txt ./tests/02/*gra-lr.txt
	rm ./tests/07/*gra.txt ./tests/07/*lex.txt ./tests/07/*gra-lr.txt
	rm ./tests/08/*gra.txt ./tests/08/*lex.txt ./tests/08/*gra-lr.txt
	rm ./tests/10/*gra.txt ./tests/10/*lex.txt ./tests/10/*gra-lr.txt



